package service;

import javax.persistence.EntityManager;

import entities.Broker;
import entities.JPAUtil;
import entities.User;

public class Authentication {
	//private EntityManager entityManager = JPAUtil.getCurrentEntityManager();
		
	public static User Login(String userName){
		//EntityManager.
		EntityManager entityManager = JPAUtil.getCurrentEntityManager();
		entityManager.getTransaction().begin();
		User user = (User) entityManager.createQuery("select u from User u where username='"+userName+"'").getSingleResult();
		if (user.getClass() == Broker.class)
			return new Broker();
		//user.getClass().getName(
		return user;
		
	}
	
	public void Register(){
		
	}
}
